package cn.mw.cmdb.entity;

import cn.mw.cmdb.enums.TableViewTypeEnum;
import cn.mw.cmdb.service.ServiceChoose;
import cn.mw.cmdb.service.impl.ModelVendorServiceImpl;
import cn.mw.cmdb.util.DataCreateInfo;
import cn.mw.components.mongodb.anno.AutoId;
import cn.mw.components.mongodb.anno.CMDBProperty;
import cn.mw.microMonitorCommon.api.cmdb.TreeView;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;

@Data
@Document("mw_cmdbmd_vendor_icon")
public class ModelVendorInfo implements ServiceChoose, TreeView, DataCreateInfo {
    @CMDBProperty(searchType = PropertyTypeString.ID, searchPrefix = "_")
    @AutoId
    @Schema(description = "id")
    protected String id;

    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "厂商中文名称")
    protected String vendorCN;

    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "厂商英文名称")
    protected String vendorUS;

    @CMDBProperty
    @Schema(description = "小图标")
    protected String vendorSmallIcon;

    @CMDBProperty
    @Schema(description = "大图标'")
    protected String vendorLargeIcon;

    @CMDBProperty
    @Schema(description = "图标类型： 0-系统定义，1-用户上传")
    protected String customFlag;

    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "备注")
    protected String description;

    @CMDBProperty(searchType = PropertyTypeString.ID,keywordSearch = true)
    @Schema(description = "创建人")
    protected Long creater;

    @CMDBProperty(searchType = PropertyTypeTime.ID)
    @Schema(description = "创建时间")
    protected Date createTime;

    @CMDBProperty(searchType = PropertyTypeString.ID,keywordSearch = true)
    @Schema(description = "修改人")
    protected Long modifier;

    @CMDBProperty(searchType = PropertyTypeTime.ID)
    @Schema(description = "修改时间")
    protected Date modificationTime;

    @CMDBProperty(logicDel = true)
    protected Boolean delFlag = false;

    private int count;

    private String itemAssetsStatus;

    private List<String> childStatus;

    @Override
    @Schema(description = "模型服务Id")
    public String getServiceId() {
        return ModelVendorServiceImpl.ID;
    }

    @Override
    public Object getParentId() {
        return null;
    }

    @Override
    public String getItemName() {
        String itemName = (StringUtils.hasText(vendorCN) ? vendorCN : vendorUS);
        return itemName;
    }

    @Override
    public String getType() {
        return "vendor";
    }

    @Override
    public String getViewType() {
        return TableViewTypeEnum.list.getCode();
    }
}
